cmake_minimum_required (VERSION 2.6)
project (MediaHouse)

IF(CMAKE_COMPILER_IS_GNUCC)
  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmessage-length=0")
ENDIF(CMAKE_COMPILER_IS_GNUCC)
IF(CMAKE_COMPILER_IS_GNUCXX)
  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmessage-length=0")
ENDIF(CMAKE_COMPILER_IS_GNUCXX)

set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules/")
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/libs/soci/src/cmake ${CMAKE_MODULE_PATH})
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/libs/soci/src/cmake/modules ${CMAKE_MODULE_PATH})

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")

# The version number.
set (MediaHouse_VERSION_MAJOR 0)
set (MediaHouse_VERSION_MINOR 1)
 
set (wxWidgets_USE_UNICODE ON)
if(WIN32)
  set(wxWidgets_USE_STATIC ON)
endif(WIN32)

FIND_PACKAGE(wxWidgets COMPONENTS core base adv REQUIRED)

FIND_PACKAGE(Sqlite3 REQUIRED)

# configure a header file to pass some of the CMake settings
# to the source code
configure_file (
  "${PROJECT_SOURCE_DIR}/MediaHouseConfig.h.in"
  "${PROJECT_BINARY_DIR}/mediahouseconfig.h"
  )

enable_testing()

add_subdirectory(libs)
 
# add the binary tree to the search path for include files
# so that we will find TutorialConfig.h
include_directories("${PROJECT_BINARY_DIR}")
include_directories("${PROJECT_SOURCE_DIR}/includes")
include_directories("${SQLITE3_INCLUDE_DIR}")
include( "${wxWidgets_USE_FILE}" )
include_directories("${PROJECT_SOURCE_DIR}/libs/hiberlite/include")
include_directories("${PROJECT_SOURCE_DIR}/libs/soci/src/core")
include_directories("${PROJECT_SOURCE_DIR}/libs/soci/src/backends/sqlite3")

add_subdirectory(addons)

get_property(Lib_Addons_Fs_Scanner_Includes GLOBAL PROPERTY Lib_Addons_Fs_Scanner_Includes)
include_directories("${Lib_Addons_Fs_Scanner_Includes}")

get_property(Lib_Addons_Txt_Media_Includes GLOBAL PROPERTY Lib_Addons_Txt_Media_Includes)
include_directories("${Lib_Addons_Txt_Media_Includes}")

aux_source_directory("${PROJECT_SOURCE_DIR}/src/addon" MediaHouse_Source_Addon)
aux_source_directory("${PROJECT_SOURCE_DIR}/src/core" MediaHouse_Source_Core)
aux_source_directory("${PROJECT_SOURCE_DIR}/src" MediaHouse_Source)

add_executable(mediahouse ${MediaHouse_Source}
	${MediaHouse_Source_Addon} ${MediaHouse_Source_Core} )
target_link_libraries(mediahouse Hiberlite)
target_link_libraries(mediahouse Lib_Addons_Fs_Scanner)
target_link_libraries(mediahouse Lib_Addons_Txt_Media)
target_link_libraries(mediahouse soci_core-static soci_sqlite3-static)
target_link_libraries(mediahouse ${wxWidgets_LIBRARIES} ${SQLITE3_LIBRARY})

add_subdirectory(tests)

install (TARGETS mediahouse DESTINATION bin)
